﻿function onSuccess(result) {
    if (result.status === 200) {
        $('#editorModal').modal('hide');
        $('#formctnr').html('');

        var item = $('.media[data-src="' + result.relative + '"]');        
        if (item.length > 0) {
            item.replaceWith(result.html);
        } else {
            $('.gallery').append(result.html);
        }

        $("img.lazy").lazyload({
            effect: "fadeIn",
            failure_limit: 3,
            data_attribute: 'src',
            placeholder: '/Content/images/lazyplaceholder.png'
        });
    } else {
        Messenger().post({
            message: result.message,
            type: 'error',
            showCloseButton: true
        });
    }
}